package com.cloud.stream2.partition;

import com.cloud.stream2.model.Student;
import org.springframework.cloud.stream.binder.PartitionKeyExtractorStrategy;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;

/**
 * @author shengtao
 * @Description: 自定义分区按照studeng的id
 * @date 2019/06/04 13:43
 */
@Component
public class CustomPartition implements PartitionKeyExtractorStrategy {
    @Override
    public Object extractKey(Message<?> message) {
        Student student = (Student) message.getPayload();
        return student.getId();
    }
}
